import math
t=0
while t == 0:
    n = int(input("边数n="))  # 输入边数
    if n <= 0:
        print("数据错误，请重新输入")
        t=0
    else:
        a = 360 / n  # 计算中心角角度数
        b = 180 - a  # 计算内角度数
        A = math.radians(a)
        B = math.radians(b)
        t=1
        x = input("选择 输入边长：I,输入外径:R，输入内径：r     ")  # 选择输入内容
        if x == "I":
            t1=0
            while t1==0:
                I = int(input("请输入I="))
                if I <= 0:
                    print("数据错误，请重新输入")
                    t1=0
                else:
                    L = n * I  # 计算周长
                    R = math.sin(B / 2) * I / math.sin(A)  # 计算多边形外径
                    r = math.cos(A / 2) * R  # 计算多边形内径
                    s = pow(R, 2) * math.sin(A) * n / 2  # 计算多边形面积
                    print("多边形面积", s)
                    print("周长", L)
                    print("中心角角度数", a)
                    print("内角度数", b)
                    print("多边形外径", R)
                    print("多边形内径", r)
                    t1=1
        elif x == "R":
            t2=0
            while t2 == 0:
                R = float(input("请输入R="))
                if R <= 0:
                    print("数据错误，请重新输入")
                    t2=0
                else:
                    I = 2 * R * math.sin(A / 2)  # 计算边长
                    L = n * I  # 计算周长
                    r = math.cos(A / 2) * R  # 计算多边形内径
                    s = pow(R, 2) * math.sin(A) * n / 2  # 计算多边形面积
                    print("多边形面积", s)
                    print("周长", L)
                    print("中心角角度数", a)
                    print("内角度数", b)
                    print("多边形边长", I)
                    print("多边形内径", r)
                    t2=1
        elif x == "r":
            r = float(input("请输入r="))
            t3=0
            while t3==0:
                if r <= 0:
                    print("数据错误，请重新输入")
                    t3=0
                else:
                    R = r / math.cos(A / 2)  # 计算多边形外径
                    I = R * math.sin(A) / math.sin(B / 2)  # 计算边长
                    L = n * I  # 计算周长
                    s = pow(R, 2) * math.sin(A) * n / 2  # 计算多边形面积
                    print("多边形面积", s)
                    print("周长", L)
                    print("中心角角度数", a)
                    print("内角度数", b)
                    print("多边形外径", R)
                    print("多边形内径", r)
                    t3=1


